﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YXShop.TemplateAction
{
    public partial class LabelParse
    {
        public string MemberLogin()
        {
            string mystyle = this.Label_Inserted;
            string Option = this.GetParamValue("YX:Option");
            StringBuilder shtml = new StringBuilder();
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            string strContent = mystyle;
            if (Option.Equals("LoginForm"))
            {
               if(strContent.IndexOf("[#login_image]")>-1)
               {
                   strContent = strContent.Replace("[#login_image]", "<img src=\""+sp.DummyPaht+sp.WebSiteTemplatePath+"/images/login_01.jpg\" alt=\"登陆\" />");
               }
               if (strContent.IndexOf("[#login_name]")>-1)
               {
                  strContent= strContent.Replace("[#login_name]","<input type=\"text\" id=\"txtLoginName\" name=\"txtLoginName\" style=\"width:150px; height:20px\" onpropertychange=\"MaxLength(this, 20)\" /><span id=\"spanName\" style=\"color:Red\"></span>");
               }
               if (strContent.IndexOf("[#login_pass]")>-1)
               {
                   strContent = strContent.Replace("[#login_pass]", "<input  type=\"password\" id=\"txtPassword\" name=\"txtPassword\" style=\"width:150px; height:20px\" onpropertychange=\"MaxLength(this, 20)\" /><span id=\"spanPass\" style=\"color:Red\"></span>");
               }
               if (strContent.IndexOf("[#login_validate]")>-1)
               {
                 
                   if (sp.Isloginvalidate)
                   {
                       //后台设置需要验证码
                       strContent = strContent.Replace("[#login_validate]", "<input type=\"text\" name=\"txtCode\" id=\"txtCode\" style=\" width:50px; height:20px\"/>&nbsp;&nbsp;<img alt=\"点击刷新验证码\" onclick=\"this.src='" + sp.DummyPaht + "admin/plugin/check_code.aspx?rdm='+Math.random();\" src=\"" + sp.DummyPaht + "admin/plugin/check_code.aspx\" class=\"pointer\"/>");
                   }
                   else
                   {   //No
                      strContent = strContent.Replace("[#login_validate]", "<input type=\"hidden\" name=\"txtCode\" id=\"txtCode\" style=\" width:50px;\"/>");
                   }
               }
               if (strContent.IndexOf("[#login_button]")>-1)
               {
                   strContent = strContent.Replace("[#login_button]", "<input id=\"loginButton\" type=\"button\" onclick=\"javascript:CheckLogin(txtLoginName.value,txtPassword.value,(txtCode.value).toUpperCase())\" />");
               }
               if (strContent.IndexOf("[#login_enrol]")>-1)
               {
                   string url = YXShop.TemplateAction.Common.UrlStr("registered", "", "membercenter/");
                   strContent = strContent.Replace("[#login_enrol]", "<a href=\""+url+"\"><img src=\"" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/login_05.jpg\" alt=\"注册\" /></a>");
               }
               shtml.Append(strContent);
            }
            return shtml.ToString();
        }
    }
}
